import 'package:flutter/material.dart';

main() => runApp(MMApp());

class MMApp extends StatelessWidget {
  const MMApp({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: "Learning",
      home: MMHomePage(),
    );
  }
}

class MMHomePage extends StatelessWidget {
  const MMHomePage({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(
          "第一个Flutter程序",
          style: TextStyle(fontSize: 30),
        ),
      ),
      body: MMHomeBody2(),
    );
  }
}

class MMHomeBody extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Center(
        child: Row(
      mainAxisAlignment: MainAxisAlignment.center,
      children: [
        Checkbox(
            value: true,
            onChanged: (value) {
              print(value);
            }),
        Text(
          "同意协议",
          style: TextStyle(fontSize: 20, color: Colors.blue),
        )
      ],
    ));
  }
}

class MMHomeBody2 extends StatefulWidget {
  const MMHomeBody2({Key? key}) : super(key: key);

  @override
  _MMHomeBody2State createState() => _MMHomeBody2State();
}

class _MMHomeBody2State extends State<MMHomeBody2> {
  var flag = true;
  @override
  Widget build(BuildContext context) {
    return Center(
        child: Row(
      mainAxisAlignment: MainAxisAlignment.center,
      children: [
        Checkbox(
            value: flag,
            onChanged: (value) {
              setState(() {
                flag = value!;
              });
              print(value);
            }),
        Text(
          "同意协议",
          style: TextStyle(fontSize: 20, color: Colors.blue),
        )
      ],
    ));
  }
}

Widget test_center() {
  // 传入Wiget , 万物皆是 Wiget
  // App 准备阶段
  return Center(
      child: Text(
    "hello world",
    textDirection: TextDirection.ltr,
    style: TextStyle(fontSize: 20, color: Colors.red),
  ));
}
